package karaokestrong.servlets;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import karaokestrong.excepcion.DAOExcepcion;
//import karaokestrong.modelo.Local;
import karaokestrong.modelo.Sala;
//import karaokestrong.negocio.GestionLocal;
import karaokestrong.negocio.GestionSala;

/**
 * Servlet implementation class ServletLocalListar
 */
@WebServlet("/ServletSalaListar")
public class ServletSalaListar extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServletSalaListar() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		GestionSala salaservlet = new GestionSala();
		
		try{

			Collection<Sala> listado = salaservlet.listarSala();
			
			request.setAttribute("Salas_Registradas_Listar", listado);
			
			//request.getRequestDispatcher("formlistarlocal.jsp").forward(request, response);
			
			RequestDispatcher rd = request.getRequestDispatcher("formSalaListar.jsp");
			rd.forward(request, response);
			
			
			} catch (DAOExcepcion e) {
				System.out.println("Fallo Listar: " + e.getMessage());
			}
		
		
	}

}
